/*
 * ikakeibo 0.6.0
 * Copyright (C)2009 wateray and contributors
 * wateray@gmail.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package com.maven.qqspider.util.log4j;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.maven.qqspider.common.Constant;
import com.maven.qqspider.util.ResourceLoader;
/**
 * @author wateray
 *
 */
public class Log {
  private  static Logger logger ;
  
  public static Logger getLogger(){
	  return getLogger(Log.class);
  }
  public static Logger getLogger(Class<? extends Object> clazz){
//	  if(logger == null){
		  logger =  Logger.getLogger(clazz);
//	  }
	  PropertyConfigurator.configure(ResourceLoader.getFileURL(Constant.LOG4J_FILE));
	  logger.setLevel(Level.INFO);
	  return logger;
  }
  public static int test(){
	  return 10 /0;
	  
  }
  public static void main(String[] args){
	Logger logger = Log.getLogger();
  	logger.debug("debug test.");
  	logger.info("Info test");
  	try{test();}
  	catch(Exception t){
  		logger.error(t.getMessage(), t);
  	}
  }
}
